/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.bioinfseq.bioinfmultiseq;

import org.biojava3.alignment.template.GapPenalty;

/**
 *
 * @author Bartek
 */
public class CustomPenalty implements GapPenalty {
    private short  ep;
    private short op;
    private GapPenalty.Type type;

    public CustomPenalty(short op, short ep) {
        this.op = (short) -Math.abs(op);
        this.ep = (short) -Math.abs(ep);
        setType();
    }   
    
    @Override
    public short getExtensionPenalty() {
        return this.ep;
    }

    @Override
    public short getOpenPenalty() {
        return this.op;
    }

    @Override
    public Type getType() {
        return Type.CONSTANT;
    }

    @Override
    public void setExtensionPenalty(short gep) {
    }

    @Override
    public void setOpenPenalty(short gop) {
    }

    private void setType() {
        if(ep == 0){
            type = GapPenalty.Type.CONSTANT;
        }
        if(op == 0){
            type = GapPenalty.Type.LINEAR;
        }
        if(ep != 0 && op != 0){
            type = GapPenalty.Type.AFFINE;
        }
    }
    
}
